<!-- 
此组件初始化时不会自动加载数据，请在mounted中 this.$refs.[].initData()
如果放在dialog里面的吗，请在dialog的open事件中用this.$nextTick进行加载
 -->
<template>
  <div>
    <list id-key="id" ref="list" unit="客户抬头" :disabled="disabled" :show-query="showQuery" show-checkbox
      :query-params="queryParams" :expand-query="expandQuery" :show-summary="showSummary" :page="page"
      :get-page-list-func="api.getPageList">
      <template #toolbar-left>
      <slot name="toolbar-left"></slot>
    </template>
      <template #query>
        <!-- <el-form-item label="ID">
            <el-input v-model.trim="queryParams.id" clearable></el-input>
          </el-form-item> -->
        <div>
          <el-form-item label="抬头名称">
            <el-input v-model.trim="queryParams.name" placeholder="抬头名称" clearable></el-input>
          </el-form-item>
          <el-form-item label="税号">
            <el-input v-model.trim="queryParams.taxNo" placeholder="抬头税号" clearable></el-input>
          </el-form-item>
          <el-form-item label="地址">
            <el-input v-model.trim="queryParams.address" placeholder="地址" clearable></el-input>
          </el-form-item>
        <el-form-item label="所属客户">
          <el-input v-model.trim="queryParams.customerName" placeholder="所属客户" clearable></el-input>
        </el-form-item>
        <!-- <el-form-item label="发票状态">
            <el-select
              v-model="queryParams.statuses"
              clearable
              multiple
              collapse-tags
            >
              <el-option
                label="新增蓝票"
                :value="1"
              ></el-option>
              <el-option
                label="冲红红票"
                :value="3"
              ></el-option>
              <el-option
                label="作废票"
                :value="2"
              ></el-option>
              <el-option
                label="开票失败"
                  :value="6"
                ></el-option>
              </el-select>
            </el-form-item> -->
        </div>
        <div>
          <el-form-item label="抬头ID">
            <el-input v-model="queryParams.idString" placeholder="抬头ID，以,或空格分隔" clearable
              style="width:800px;max-width:none"></el-input>
          </el-form-item>
        </div>
        <div>
          <el-form-item label="创建日期">
            <el-row style="width:300px">
              <el-col :span="11">
                <el-form-item>
                  <el-date-picker v-model.trim="queryParams.createDateBegin" placeholder="开始日期" value-format="yyyy-MM-dd"
                    style="width: 100%"></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="2">至</el-col>
              <el-col :span="11">
                <el-form-item>
                  <el-date-picker v-model.trim="queryParams.createDateEnd" placeholder="结束日期" value-format="yyyy-MM-dd"
                    style="width: 100%"></el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form-item>
        </div>
    </template>
    <template #column>

      <!-- <el-table-column
          prop="status"
          width="90"
          label="发票状态"
          align="center"
        >
          <template #default="{ row }">
            <el-tooltip :content="row.nuoNuoMessage" :disabled="row.status!=6">
              <el-tag :type="getStatusType(row.status)">{{
                row.statusText
                }}</el-tag></el-tooltip
              >
            </template>
          </el-table-column> -->
        <el-table-column prop="id" width="200" label="ID" show-overflow-tooltip />
        <el-table-column prop="name" min-width="180" label="抬头名称" show-overflow-tooltip>
        <template #default="{ row }">
          <el-tag v-if="!row.isValid" type="danger" style="margin-right:5px">已失效</el-tag>
          {{ row.name }}
            <!-- <span
                class="c-link"
                @click="openDetail(row.id)"
              >{{row.name}}</span> -->
          </template>
        </el-table-column>
        <el-table-column prop="customerName" min-width="180" label="所属客户" show-overflow-tooltip />
        <el-table-column prop="code" width="150" label="抬头代码" show-overflow-tooltip />
        <el-table-column prop="typeName" width="100" label="发票类型" />
        <el-table-column prop="tfn" width="150" label="税号" show-overflow-tooltip />
        <el-table-column prop="address" width="180" label="地址电话" show-overflow-tooltip />
        <el-table-column prop="tel" width="180" label="电话" show-overflow-tooltip />
        <el-table-column prop="bank1" width="180" label="银行1" show-overflow-tooltip />
        <el-table-column prop="creationTime" width="120" label="创建日期" sortable="custom">
          <template v-slot="{ row }">
          <span>{{ row.creationTime | toShortDatetimeString }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column
          prop="lastModificationTime"
          width="120"
          label="更新时间"
          sortable="custom"
        >
            <template v-slot="{ row }">
              <span>{{ row.lastModificationTime | toShortDatetimeString }}</span>
            </template>
          </el-table-column> -->
        <!-- slot[column] -->
        <slot name="column"></slot>
        <!--/ slot[column]-->
      </template>
    </list>
    <detail-dialog ref="detailDialog" :in-dialog="inDialog" />
  </div>
</template>
<script>
import listMixin from "@/mixins/list";
import list from "@/components/common/list";
import detailDialog from "@/components/crm/customer/detailDialog";
import api from "@/api/crm/customerTitle";
export default {
  mixins: [listMixin],
  components: {
    list,
    detailDialog,
  },
  props: {},
  data() {
    return {
      //查询条件字段
      queryParams: {
        name: "",
        enName: "",
        zhName: "",
        address: "",
        statuses: [],
      },
      api,
    };
  },
  methods: {
    getStatusType(status) {
      var text = "";
      switch (status) {
        case 0:
          text = "info";
          break;
        case 1:
          text = "";
          break;
        case 2:
          //作废
          text = "info";
          break;
        case 3:
          //冲红
          text = "warning";
          break;
        case 6:
          text = "danger";
          break;
      }
      return text;
    },
    openDetail(id) {
      this.$refs.detailDialog.openDetail(id);
    },
  },
};
</script>